// 删除框
<style scoped>
</style>
<template>
  <div>
    <Modal v-model="delModal" width="360">
        <p slot="header" style="color:#f60;text-align:center">
            <Icon type="information-circled"></Icon>
            <span>删除确认</span>
        </p>
        <div style="text-align:center">
            <p>确认删除该个{{title}}？</p>
            <p>是否继续删除？</p>
        </div>
        <div slot="footer">
            <Button type="error" size="large" long @click="del">删除</Button>
        </div>
    </Modal>
  </div>
</template>
<script>
import { ajaxPost } from 'global/axios'
import storage from 'good-storage'
export default {
  data () {
    return {
      delModal: false
    }
  },
  props: {
    title: {
      type: String,
      default: ''
    },
    delArr: {
      type: Array,
      default: []
    },
    url: {
      type: String,
      default: ''
    }
  },
  methods: {
    showModal () {
      this.delModal = !this.delModal
    },
    del () {
      var _ids = ''
      for (let i = 0; i < this.delArr.length; i++) {
        if (i == this.delArr.length - 1) {
          _ids += this.delArr[i]._id
        } else {
          _ids += this.delArr[i]._id + ','
        }
      }
      let params = {
        data: {
          _ids: _ids
        },
        url: this.url,
        token: storage.session.get('token'),
        success: res => {
          if (res.data.code == '0000') {
            this.$Loading.finish()
            this.$Message.success({
              content: '删除成功'
            })
            this.delModal = false
            this.$emit('del')
          } else {
            this.$Message.warning({
              content: res.data.message
            })
          }
        }
      }
      ajaxPost(params)
    }
  }
}
</script>
